package com.imooc.controller;

import com.imooc.dto.OrderDTO;
import com.imooc.message.StreamClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by Administrator on 2019/3/20.
 * 用于测试发送消息队列
 */
@RestController
public class SendMessageController {

    @Autowired
    private StreamClient streamClient;

    //发送消息
    @GetMapping("/sendMessage")
    public void process() {
        String message = "now " + new Date();
        streamClient.output().send(MessageBuilder.withPayload(message).build());

    }

    @GetMapping("/sendMessage1")
    public void process1() {
        OrderDTO orderDTO = new OrderDTO();
        orderDTO.setOrderId("123456");
        streamClient.output().send(MessageBuilder.withPayload(orderDTO).build());
    }


}
